package com.ssr.master.common.impl;

import com.ssr.master.common.Base.BaseEntity;
import com.ssr.master.common.persistence.CrudDao;
import com.ssr.master.common.service.CrudService;
import com.ssr.master.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author ZhangPeng
 * @Describe //todo
 * @date
 * @updateBy
 * @other
 **/

public abstract class CrudServiceImpl<D extends CrudDao<T>,T extends BaseEntity<T>> implements CrudService<T>{

    @Autowired
    private D dao;


    public CrudServiceImpl () {
    }

    public T get (String id) {
        return this.dao.get(id);
    }

    public T get(T entity) {
        return this.dao.get(entity);
    }

    public List<T> findList(T entity) {
        if (StringUtils.isBlank(entity.getOrgId())) {
            entity.updateOrgId();
        }

        return this.dao.findList(entity);
    }
}
